package service

import (
	"e_order_trace/utils"
	"github.com/gin-gonic/gin"
)

//订单追踪
func OrderTrace(c *gin.Context) {
	logisticsNo := c.Param("logisticsNo")
	//使用运单号查询
	sqlStr := "SELECT trace_lines as traceLine,company_type,order_no,logistics_no FROM order_logistrace where logistics_no = ? " +
		"union all SELECT trace_lines as traceLine,company_type,order_no,logistics_no FROM cur_order_logistrace where logistics_no = ? "
	_, data, _ := utils.DoQuery(utils.SqlDb, sqlStr, logisticsNo, logisticsNo)
	if data == nil {
		//使用订单号查询
		sqlStr = "SELECT trace_lines as traceLine,company_type,order_no,logistics_no FROM order_logistrace where order_no = ? " +
			"union all SELECT trace_lines as traceLine,company_type,order_no,logistics_no FROM cur_order_logistrace where order_no = ? "
		_, data, _ := utils.DoQuery(utils.SqlDb, sqlStr, logisticsNo, logisticsNo)
		if data != nil {
			utils.Json(0, "查询成功", data, c)
		} else {
			utils.Json(1, "查询失败", nil, c)
			return
		}
	}
	utils.Json(0, "查询成功", data, c)
}
